# Maintainer: Biswapriyo Nath <nathbappai@gmail.com>

source "$(dirname ${BASH_SOURCE[0]})"/../mingw-w64-PKGBUILD-common/kde-frameworks5
_realname=breeze
pkgbase=mingw-w64-${_realname}-qt5
pkgname=("${MINGW_PACKAGE_PREFIX}-${_realname}-qt5")
pkgver=6.3.5
pkgrel=1
arch=('any')
mingw_arch=('ucrt64' 'clang64' 'clangarm64')
msys2_references=(
  'archlinux: breeze5'
)
pkgdesc='Artwork, styles and assets for the Breeze visual style for the Plasma Desktop (mingw-w64)'
url='https://kde.org/plasma-desktop/'
license=('spdx:GPL-3.0-or-later')
makedepends=("${MINGW_PACKAGE_PREFIX}-7zip"
             "${MINGW_PACKAGE_PREFIX}-cc"
             "${MINGW_PACKAGE_PREFIX}-extra-cmake-modules"
             "${MINGW_PACKAGE_PREFIX}-ninja"
             "${MINGW_PACKAGE_PREFIX}-python")
depends=("${MINGW_PACKAGE_PREFIX}-hicolor-icon-theme"
         "${MINGW_PACKAGE_PREFIX}-breeze"
         "${MINGW_PACKAGE_PREFIX}-breeze-icons"
         "${MINGW_PACKAGE_PREFIX}-kconfig-qt5"
         "${MINGW_PACKAGE_PREFIX}-kconfigwidgets-qt5"
         "${MINGW_PACKAGE_PREFIX}-kguiaddons-qt5"
         "${MINGW_PACKAGE_PREFIX}-kiconthemes-qt5"
         "${MINGW_PACKAGE_PREFIX}-kirigami2-qt5"
         "${MINGW_PACKAGE_PREFIX}-kwindowsystem-qt5"
         "${MINGW_PACKAGE_PREFIX}-qt5-base"
         "${MINGW_PACKAGE_PREFIX}-qt5-declarative")
groups=("${MINGW_PACKAGE_PREFIX}-plasma")
source=("https://download.kde.org/stable/plasma/${pkgver}/${_realname}-${pkgver}.tar.xz"{,.sig})
noextract=("${_realname}-${pkgver}.tar.xz")
sha256sums=('5803d8e3d4edf7de26e2df21ec28662b611a0bca505c39b991c7763dba6026ab'
            'SKIP')
validpgpkeys=('E0A3EB202F8E57528E13E72FD7574483BB57B18D') # Jonathan Esk-Riddell <jr@jriddell.org>

prepare() {
  7z x -bso0 -bsp0 "${_realname}-${pkgver}.tar.xz"
  7z x -bso0 -bsp0 -ttar "${_realname}-${pkgver}.tar"
  python "$(dirname ${BASH_SOURCE[0]})"/../mingw-w64-PKGBUILD-common/replace-symlinks.py "${_realname}-${pkgver}"
}

build() {
  mkdir -p build-${MSYSTEM} && cd build-${MSYSTEM}

  declare -a _extra_config
  if check_option "debug" "n"; then
    _extra_config+=("-DCMAKE_BUILD_TYPE=Release")
  else
    _extra_config+=("-DCMAKE_BUILD_TYPE=Debug")
  fi

  _kde_f5_build_env
  ${MINGW_PREFIX}/bin/cmake.exe \
    -G "Ninja" \
    "${_kde_f5_KDE_INSTALL_DIRS[@]}" \
    -DBUILD_TESTING=OFF \
    -DECM_DIR=${MINGW_PREFIX}/share/ECM \
    -DCMAKE_DISABLE_FIND_PACKAGE_KF5FrameworkIntegration=ON \
    -DWITH_DECORATIONS=OFF \
    -DBUILD_QT6=OFF \
    "${_extra_config[@]}" \
    ../${_realname}-${pkgver}

  ${MINGW_PREFIX}/bin/cmake.exe --build ./
}

package() {
  cd build-${MSYSTEM}
  DESTDIR="${pkgdir}" ${MINGW_PREFIX}/bin/cmake.exe --install ./

  # Remove file conflict with breeze kf6
  rm -r "${pkgdir}${MINGW_PREFIX}"/bin/data
}
